# the minimum version of CMake.
cmake_minimum_required(VERSION 3.4.1)
project(NdkDrawing)

# 允许基于masm的Intel汇编
#enable_language(ml) # ASM_MASM
## 包含masm32 sdk的头文件目录
#include_directories(D:/masm32/include)
## 包含masm32 sdk的库文件目录
#link_directories(D:/masm32/lib)

set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fms-extensions -fdeclspec -ftls-model=global-dynamic -fno-emulated-tls")

# 包含头文件
include_directories(${NATIVERENDER_ROOT_PATH}
                    ${NATIVERENDER_ROOT_PATH}/include)

if(DEFINED PACKAGE_FIND_FILE)
    include(${PACKAGE_FIND_FILE})
endif()

include_directories(${NATIVERENDER_ROOT_PATH}
                    ${NATIVERENDER_ROOT_PATH}/include)

add_library(ndkDrawing SHARED native_bridge.cpp dl_util.cpp) # , aarch64-tlsdesc.s

find_library(
              hilog-lib
              hilog_ndk.z )

add_library(sharedx SHARED shared.cpp)

add_library(mainx SHARED main.cpp)


# 链接库目录
target_link_directories(ndkDrawing PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/)
#target_link_directories(ndkDrawing PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/third_party/curlDownload/libs/${OHOS_ARCH}/)

#add_library(hello SHARED IMPORTED)
#set_target_properties(hello
#    PROPERTIES
#    IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/third_party/hello/libs/${OHOS_ARCH}/libhello.so)

#add_library(curlDownload SHARED IMPORTED)
#set_target_properties(curlDownload
#    PROPERTIES
#    IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/third_party/curlDownload/libs/${OHOS_ARCH}/libcurlDownload.so)

#add_library(curl SHARED IMPORTED)
#set_target_properties(curl
#    PROPERTIES
#    IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/third_party/curlDownload/libs/${OHOS_ARCH}/libcurl.so)

#add_library(curl SHARED IMPORTED)
#set_target_properties(curl
#    PROPERTIES
#    IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/third_party/curlDownload/libs/${OHOS_ARCH}/libcurl.so.4)
#
#add_library(nghttp SHARED IMPORTED)
#set_target_properties(nghttp
#    PROPERTIES
#    IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/third_party/curlDownload/libs/${OHOS_ARCH}/libnghttp2.so.14)
#
#add_library(zstd SHARED IMPORTED)
#set_target_properties(zstd
#    PROPERTIES
#    IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/third_party/curlDownload/libs/${OHOS_ARCH}/libzstd.so)

#set(LIBRARY_DIR "${NATIVERENDER_ROOT_PATH}/../../../entry/build/default/intermediates/libs/default/${OHOS_ARCH}/")
# 指定目标链接的库
target_link_libraries(ndkDrawing PUBLIC libace_napi.z.so)
target_link_libraries(ndkDrawing PUBLIC ${hilog-lib})
target_link_libraries(ndkDrawing PUBLIC libnative_window.so)
target_link_libraries(ndkDrawing PUBLIC libnative_drawing.so)
target_link_libraries(ndkDrawing PUBLIC libpixelmap_ndk.z.so)
target_link_libraries(ndkDrawing PUBLIC libimage_source_ndk.z.so)
target_link_libraries(ndkDrawing PUBLIC librawfile.z.so)
#target_link_libraries(ndkDrawing PUBLIC libcurlDownload.so)
target_link_libraries(ndkDrawing PUBLIC libhello.so)

#set(ENV(LD_PRELOAD) libhello.so)
#target_link_libraries(ndkDrawing PUBLIC libace_napi.z.so hello)
#target_link_libraries(ndkDrawing PUBLIC libace_napi.z.so libcurlDownload.so libhilog_ndk.z.so librawfile.z.so)

#target_link_libraries(ndkDrawing PUBLIC libace_napi.z.so curlDownload curl nghttp zstd)


target_link_libraries(mainx PUBLIC sharedx)